perm filename WEAVE.DIF[WEB,ALS]2 blob
sn#659954 filedate 1982-05-17 generic text, type C, neo UTF8
COMMENT ⊗ VALID 00005 PAGES
C REC PAGE DESCRIPTION
C00001 00001
C00002 00002 1) WEAVE.CH[WEB,ALS] and 2) WEAVE.CH[WEB,DEK] 5-17-82 08:20 pages 1,1
C00007 00003 1) WEAVE.CH[WEB,ALS] and 2) WEAVE.CH[WEB,DEK] 5-17-82 08:20 pages 1,1
C00011 00004 1) WEAVE.CH[WEB,ALS] and 2) WEAVE.CH[WEB,DEK] 5-17-82 08:20 pages 1,1
C00015 00005 1) WEAVE.CH[WEB,ALS] and 2) WEAVE.CH[WEB,DEK] 5-17-82 08:20 pages 1,1
C00018 ENDMK
C⊗;
1) WEAVE.CH[WEB,ALS] and 2) WEAVE.CH[WEB,DEK] 5-17-82 08:20 pages 1,1
**** File 1) WEAVE.CH[WEB,ALS]/1P/1L
**** File 2) WEAVE.CH[WEB,DEK]/1P/1L
2) COMMENT ⊗ VALID 00013 PAGES
2) C REC PAGE DESCRIPTION
2) C00001 00001
2) C00003 00002 @ Some of this code is optional for use when debugging only
2) C00005 00003 @ Here now is the system-dependent part of the character set.
2) C00006 00004 @ The following code opens the input files. Since these files were listed
2) C00008 00005 @ The following code opens |tex_file|. Since this file was listed in the
2) C00009 00006 @ Input goes into an array called |buffer|.
2) C00010 00007 @p function input_ln(var f:text_file):boolean
2) C00012 00008 @<Print error location based on input buffer@>=
2) C00014 00009 @ When we wish to append the character $c$ to the output buffer, we write
2) C00016 00010 @<Print error message and prepare to write...@>=
2) C00018 00011 @ @<If tracing,...@>=
2) C00019 00012 @<Output the code...@>=
2) C00020 00013 @<Phase III: Output the cross-reference index@>=
2) C00021 ENDMK
2) C⊗;
2) @ Some of this code is optional for use when debugging only;
2) such material is enclosed between the delimiters |debug| and $|gubed|$.
2) Other parts, delimited by |stat| and $|tats|$, are optionally included
2) if statistics about \.{WEAVE}'s memory usage are desired.
2) @d debug==@{ {change this to `$\\{debug}\eqv\null$' when debugging}
2) @d gubed==@} {change this to `$\\{gubed}\eqv\null$' when debugging}
2) @f debug==begin
2) @f gubed==end
2) @#
2) @d stat== {change this to `$\\{stat}\eqv\.{@@\}}$' when not
2) gathering usage statistics}
2) @d tats== {change this to `$\\{tats}\eqv\.{@@\}}$' when not
2) gathering usage statistics}
2) @f stat==begin
2) @f tats==end
2) @↑system dependencies@>@↑changes for {\mc SAIL}@>@z
2) @ Here now is the system-dependent part of the character set.
2) The code shown here is intended to be used on the Stanford {\sc SAIL} system,
2) and at other installations like CMU and ISI where essentially the same
2) extended character set is used. The fact that {\sc SAIL} has |'}'| in the
2) wrong place turns out to cause no difficulty in this case.
2) @<Set initial values...@>=
2) for i←1 to @'37 do xchr[i]←chr(i);
2) xchr[left_arrow]←chr(@'137);
2) xchr[not_equal]←chr(@'33);
2) xchr[@'33]←chr(@'176);
2) @↑system dependencies@>@↑changes for {\mc SAIL}@>@z
2) @ The following code opens the input files. Since these files were listed
2) in the program header, we assume that the \PASCAL\ runtime system has
1) WEAVE.CH[WEB,ALS] and 2) WEAVE.CH[WEB,DEK] 5-17-82 08:20 pages 1,1
2) already checked that suitable file names have been given; therefore
2) no additional error checking needs to be done. We open the files
2) in a special mode that allows us to distinguish |form_feed| from
2) |carriage_return|. We will see below that \.{WEAVE} reads through the
2) entire input twice.
2) Local scuttlebutt says that nineteen buffers gives best results at {\mc SAIL}.
2) @p procedure open_input; {prepare to read |web_file| and |change_file|}
2) begin reset(web_file,'','/E/N:19'); reset(change_file,'','/E/N:19');
2) end;
2) @↑system dependencies@>@↑changes for {\mc SAIL}@>@z
2) @ The following code opens |tex_file|. Since this file was listed in the
2) program header, we assume that the \PASCAL\ runtime system has checked
2) that a suitable external file name has been given.
2) @↑system dependencies@>
2) @<Set init...@>=
2) rewrite(tex_file,'','/N:19');
2) @↑system dependencies@>@↑changes for {\mc SAIL}@>@z
2) @ Input goes into an array called |buffer|.
2) We use a special feature of the local \PASCAL\ that
2) reads text into another array |aux_buffer| first, thus saving
2) a bunch of procedure-call overhead.
2) @<Globals...@>=@!buffer: array[0..long_buf_size] of ascii_code;
2) @!aux_buffer:array[0..buf_size] of text_char;
2) @↑system dependencies@>@↑changes for {\mc SAIL}@>@z
2) @p function input_ln(var f:text_file):boolean;
2) {inputs a line or returns |false|}
2) label restart;
2) var n: integer; {the number of characters input by Hedrick's extended |read|}
2) @!k:0..buf_size; {index into the buffers}
2) begin restart: if eof(f) then
2) begin limit←0; input_ln←false;
2) end
2) else begin read(f,aux_buffer:n);
2) if (line=1)∧(n=29)∧(aux_buffer[0]='C')∧(aux_buffer[8]=chr(@'26)) then
2) begin while (f↑≠chr(form_feed))∧(not eof(f)) do
2) begin read_ln(f);
2) read(f,aux_buffer:n); {skip file directory page}
2) end;
2) end;
2) if n<buf_size then
2) begin limit←n;
2) if n>0 then for k←0 to limit-1 do buffer[k]←xord[aux_buffer[k]]
2) else if f↑=chr(form_feed) then
2) begin line←((line div @'200000)+1)*@'200000+1;
2) read_ln(f); goto restart;
2) end;
2) end
2) else begin limit←buf_size-1;
1) WEAVE.CH[WEB,ALS] and 2) WEAVE.CH[WEB,DEK] 5-17-82 08:20 pages 1,1
2) for k←0 to limit-1 do buffer[k]←xord[aux_buffer[k]];
2) print_nl('! Input line too long'); error;
2) @.Input line too long@>
2) while not eoln(f) do read(f,aux_buffer);
2) end;
2) read_ln(f); input_ln←true;
2) end;
2) end;
2) @↑system dependencies@>@↑changes for {\mc SAIL}@>@z
2) @<Print error location based on input buffer@>=
2) begin if changing then print('. (change file ')@+else print('. (');
2) print_ln('p.',1+(line div @'200000):0,',l.', line mod @'200000:0, ')');
2) if loc≥limit then l←limit else l←loc;
2) for k←1 to l do
2) if buffer[k-1]=tab_mark then print(' ')
2) else print(xchr[buffer[k-1]]); {print the characters already read}
2) new_line;
2) for k←1 to l do print(' '); {space out the next line}
2) for k←l+1 to limit do print(xchr[buffer[k-1]]); {print the part not yet read}
2) if buffer[limit]="|" then print(xchr["|"]);
2) {end of \PASCAL\ text in module names}
2) print(' '); {this space separates the message from future asterisks}
2) end
2) @↑system dependencies@>@↑changes for {\mc SAIL}@>@z
2) @ When we wish to append the character $c$ to the output buffer, we write
2) `$|out|(c)$'; this will cause the buffer to be emptied if it was already
2) full. Similarly, `$|out2|(c↓1)(c↓2)$' appends a pair of characters.
2) A line break will occur at a space or after a single-nonletter
2) \TEX\ control sequence. The |write_end_of_page| routine is used to
2) break the output into pages for ease in editing.
2) @d oot(#)==if out_ptr=line_length then break_out;
2) incr(out_ptr); out_buf[out_ptr]←#;
2) @d oot1(#)==oot(#)@+end
2) @d oot2(#)==oot(#)@,oot1
2) @d oot3(#)==oot(#)@,oot2
2) @d oot4(#)==oot(#)@,oot3
2) @d oot5(#)==oot(#)@,oot4
2) @d out==@+begin oot1
2) @d out2==@+begin oot2
2) @d out3==@+begin oot3
2) @d out4==@+begin oot4
2) @d out5==@+begin oot5
2) @p procedure write_end_of_page;
2) begin if out_ptr>0 then flush_buffer(out_ptr);
2) write(tex_file,xchr[form_feed]); {write a page mark}
2) out_line←((out_line div @'200000)+1)*@'200000+1;
2) end;
2) @↑system dependencies@>@↑changes for {\mc SAIL}@>@z
1) WEAVE.CH[WEB,ALS] and 2) WEAVE.CH[WEB,DEK] 5-17-82 08:20 pages 1,1
2) @<Print error message and prepare to write...@>=
2) begin print_nl('! Line had to be broken (output p.',
2) @.Line had to be broken@>
2) 1+(out_line div @'200000):0,',l.',out_line mod @'200000:0);
2) print_ln('):');
2) for k←1 to out_ptr do print(xchr[out_buf[k]]);
2) new_line; k←out_ptr; c←" ";
2) end
2) @↑system dependencies@>@↑changes for {\mc SAIL}@>@z
2) @ @<If tracing,...@>=
2) debug if tracing=2 then
2) begin print_nl('Tracing after p.',1+(line div @'200000):0,
2) ',l.',line mod @'200000:0,':');
2) if loc>50 then
2) begin print('...');
2) for k←loc-50 to loc do print(xchr[buffer[k-1]]);
2) end
2) else for k←1 to loc do print(xchr[buffer[k-1]]);
2) end
2) gubed
2) @↑system dependencies@>@↑changes for {\mc SAIL}@>@z
2) @<Output the code...@>=
2) finish_line; flush_buffer(0); {insert a blank line, it looks nice}
2) if buffer[loc-1]≠"*" then out2("\")("M")
2) @.\\M@>
2) else begin write_end_of_page;
2) out2("\")("N");
2) @.\\N@>
2) print('*',module_count:0); update_terminal; {print a progress report}
2) end;
2) out_val(module_count); out2(".")(" ")
2) @↑system dependencies@>@↑changes for {\mc SAIL}@>@z
2) @<Phase III: Output the cross-reference index@>=
2) print_nl('Writing the index...');
2) finish_line; write_end_of_page;
2) out4("\")("i")("n")("x"); finish_line;
2) @.\\inx@>
2) @<Do the first pass of sorting@>;
2) @<Sort and output the index@>;
2) write_end_of_page;
2) out4("\")("f")("i")("n"); finish_line;
2) @.\\fin@>
2) @<Output all the module names@>;
2) out4("\")("c")("o")("n"); finish_line;
2) @.\\con@>
2) print('Done.');
2) @↑system dependencies@>@↑changes for {\mc SAIL}@>@z
***************